﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using YArchitech.DataModel;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;

namespace YArchitech.HVAC
{
	public partial class ConnectionTypeForm : System.Windows.Forms.Form
	{
		public int AlignType { get; set; }

		public ConnectionTypeForm()
		{
			this.InitializeComponent();
			new YJKProcessTools().ShowInTaskbarChange(this);
			base.Icon = Resource.YArchitechIcon;
		}

		private void btnOk_Click(object sender, EventArgs e)
		{
			if (this.rboFlexDuctConnection.Checked)
			{
				this.connectionType = 1;
			}
			if (this.rdoTopAlign.Checked)
			{
				this.AlignType = 0;
			}
			else if (this.rdoMiddleAlign.Checked)
			{
				this.AlignType = 1;
			}
			else if (this.rdoBottomAlign.Checked)
			{
				this.AlignType = 2;
			}
			this.UserSettingWrite();
			base.DialogResult = DialogResult.OK;
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.Close();
		}

		private void UserSettingWrite()
		{
			this.userSetting.WriteTerminalConnectionType(this.connectionType.ToString());
			this.userSetting.WriteTerminalAlignType(this.AlignType.ToString());
		}

		private void UserSettingRead()
		{
			if (this.userSetting.GetTerminalConnectionType() == "0")
			{
				this.rboDirectConnection.Checked = true;
			}
			else
			{
				this.rboFlexDuctConnection.Checked = true;
			}
			string terminalAlignType = this.userSetting.GetTerminalAlignType();
			if (terminalAlignType == "0")
			{
				this.rdoTopAlign.Checked = true;
				return;
			}
			if (terminalAlignType == "2")
			{
				this.rdoBottomAlign.Checked = true;
				return;
			}
			this.rdoMiddleAlign.Checked = true;
		}

		private void ConnectionTypeForm_Load(object sender, EventArgs e)
		{
			this.UserSettingRead();
		}

		public int connectionType;

		private HVACUserSetting userSetting = new HVACUserSetting();
	}
}
